from django.shortcuts import render_to_response

from models import Setup

class DynamicMiddleware(object):
    def process_request(self, request):
        try:
            setup = Setup.objects.get_current()

            if setup.maintenance_state and \
               not setup.in_maintenance_white_list(request.get_full_path()):
                return render_to_response('dynamic/maintenance_state.html')
        except Exception, e:
            raise e

